package game.display;

import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;

import game.menu.Drawable;

public class Background implements Drawable {
	private static int width;
	private static int height;
	
	private ArrayList<Drawable> stuff;
	
	public Background(int width, int height, int s, int a ){
		this.width = width;
		this.height = height;
		
		stuff = new ArrayList<Drawable>();
		
		for(int count = 0; count < s; count++){
			stuff.add(new Star(((Math.random())*width),((Math.random())*height),(1 - 2*(Math.random())), (1 - 2*(Math.random()))));
		}
		for(int count = 0; count < a; count++){
			stuff.add(new Asteroid(((Math.random())*width),((Math.random())*height),(1 - 2*(Math.random())), (1 - 2*(Math.random()))));
		}
	}
	
	public static int getWidth(){
		return width;
	}
	
	public static int getHeight(){
		return height;
	}

	@Override
	public void draw(Graphics g) {
		g.setColor(Color.BLACK);
		g.fillRect(0, 0, width, height);
		
		for(Drawable d: stuff){
			if(d instanceof Star){
				((Star) d).update();
			}
			else{
				((Asteroid) d).update();
			}
			d.draw(g);
		}
	}
}
